<template>
	<view>
		<Header title="销售详情"></Header>
		<view class="top_img">
			<image :src="mood.imgId" mode="aspectFill" style="width: 100%;height: 100%;"></image>
		</view>
		<view class="canshu_box">
			<view class="canshu_boxTilte">蜂箱参数</view>
			<view class="" style="height: 30rpx;"></view>
			<view class="canshu_zi">
				<span>饲料费用/月：</span>
				<span style="color: red;">{{mood.feedCost}}元</span>
			</view>
			<view class="canshu_zi">
				<span>最低产出/月：</span>
				<span style="color: red;">{{mood.output}}g</span>
			</view>
			<view class="canshu_zi">
				<span>最低认养月数：</span>
				<span style="color: red;">{{mood.minMonth}}月</span>
			</view>
		</view>
		<view class="" style="height: 50rpx;"></view>
		<view class="canshu_box" v-if="cont=='已销售'">
			<view class="canshu_boxTilte">销售信息</view>
			<view class="" style="height: 30rpx;"></view>
			<view class="canshu_zi">
				<span>拥有人：</span>
				<span >{{mood.ownerName}}</span>
			</view>
			<view class="canshu_zi">
				<span>价格：</span>	
				<span >{{mood.money}}元</span>
			</view>
			<view class="canshu_zi" v-if="mood.buyerName">
				<span>购买人：</span>
				<span >{{mood.buyerName}}</span>
			</view>
			<view class="canshu_zi" v-if="mood.extractStatus==null|| mood.extractStatus">
				<span>提现状态：</span>
				<span v-if='mood.extractStatus===null'>未提现</span>
				<span v-if='mood.extractStatus==0'>待打款</span>
				<span v-if='mood.extractStatus==1'>已打款</span>
			</view>
			<view class="canshu_zi" v-if="mood.extractMoney">
				<span>提现金额：</span>
				<span style="color: red;" >{{mood.extractMoney}}元</span>
			</view>
			<view class="canshu_zi" v-if="mood.salesTime">
				<span>销售时间：</span>
				<span >{{mood.salesTime}}</span>
			</view>
		</view>
		<view class="" v-if="cont=='已销售'">
			<view class="buyBox" v-if='mood.extractStatus===null'>
				<view class="buyBtn" @click="subitm">立即提现</view>
			</view>
		</view>
		
		<view class="" style="height: 50rpx;"></view>
		<!-- <view class="btn_flx" v-if="mood.state==0">
			<view class="jueBtn" @click="subitm(2)">拒绝</view>
			<view style="width: 30rpx;"></view>
			<view class="jeshouBtn" @click="subitm(1)">接受</view>
		</view> -->
	</view>
</template>

<script>
	import Header from '@/components/header/header.vue'
	export default {
		components: {
			Header
		},
		data() {
			return {
				id: '',
				mood: null,
				cont:'可销售'
			}
		},
		onLoad(e) {
			this.id = e.id
			this.cont=e.cont
			this.cread()
		},
		onShareAppMessage() { // 分享到微信好友
		  // 更多参数配置，参考文档
		  return {
		    title: '冒丰数字',
		    path: '/pages/index/adopt/adopt?id='+this.id+'&shareId='+uni.getStorageSync('userId')+'&cont='+this.cont,
		    imageUrl: this.mood.imgId,
		  }
		},
		onShareTimeline() { // 分享到朋友圈
		  return {
		    title: '冒丰数字',
		    path: '/pages/index/adopt/adopt?id='+this.id+'&shareId='+uni.getStorageSync('userId')+'&cont='+this.cont,
		    imageUrl:  this.mood.imgId,
		  }
		},
		methods: {
			async subitm(e){
				let that = this 
				let res = await this.$api.request('manage/money', 'post',{
					salesRecordId:that.id,
				})
				if(res.code==200){
					uni.showToast({
						title:'提现成功',
						icon:'none'
					})
					setTimeout(()=>{that.cread()},500)
				}
			},
			async cread() {
				let res = await this.$api.request('farmer/foster/marketabilityDetails','get',{fosterId:this.id})
				this.mood = res.data
			}
		}
	}
</script>

<style scoped>
	.btn_flx {
		display: flex;
		justify-content: center;
	}

	.jueBtn {
		width: 260rpx;
		height: 80rpx;
		background-color: #757575;
		color: #fff;
		font-size: 34rpx;
		border-radius: 40rpx;
		text-align: center;
		line-height: 80rpx;
	}

	.jeshouBtn {
		width: 260rpx;
		height: 80rpx;
		background-color: #E8220F;
		color: #fff;
		font-size: 34rpx;
		border-radius: 40rpx;
		text-align: center;
		line-height: 80rpx;
	}

	.canshu_zi {
		font-size: 30rpx;
		color: #999999;
		margin-top: 15rpx;
	}

	.canshu_boxTilte {
		font-size: 36rpx;
		color: #333333;
		margin-left: 32rpx;
		padding-top: 30rpx;
		font-weight: 600;
	}

	.top_img {
		width: 750rpx;
		height: 750rpx;
		background-color: aqua;
	}

	.canshu_box {
		width: 710rpx;
		margin-left: 20rpx;
		border-radius: 10rpx;
		background-color: #fff;
		padding-bottom: 30rpx;
	}
	.buyBox {
		padding-right: 20rpx;
		box-sizing: border-box;
		width: 100%;
		height: 120rpx;
		position: fixed;
		bottom: 0rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #fff;
		box-shadow: 0rpx -5rpx 8rpx 0rpx rgba(153, 153, 153, 0.3);
	
	
	}
	.buyBtn {
		height: 98rpx;
		border-radius: 100rpx;
		width: 80%;
		background: linear-gradient(-49deg, #FE471E, #D40101);
		color: #fff;
		font-size: 36rpx;
		text-align: center;
		line-height: 98rpx;
		font-weight: bold;
	}
</style>